package com.ruoyi.web.controller.vpn;

import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.vpn.domain.dto.VpnCarmiDTO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.vpn.domain.VpnCarmi;
import com.ruoyi.vpn.service.IVpnCarmiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * carmiController
 * 
 * @author Edwin
 * @date 2024-01-08
 */
@RestController
@RequestMapping("/vpn/carmi")
public class VpnCarmiController extends BaseController
{
    @Autowired
    private IVpnCarmiService vpnCarmiService;

    /**
     * 查询carmi列表
     */
    @PreAuthorize("@ss.hasPermi('vpn:carmi:list')")
    @GetMapping("/list")
    public TableDataInfo list(VpnCarmi vpnCarmi)
    {
        startPage();
        List<VpnCarmi> list = vpnCarmiService.selectVpnCarmiList(vpnCarmi);
        return getDataTable(list);
    }

    /**
     * 导出carmi列表
     */
    @PreAuthorize("@ss.hasPermi('vpn:carmi:export')")
    @Log(title = "carmi", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VpnCarmi vpnCarmi)
    {
        List<VpnCarmi> list = vpnCarmiService.selectVpnCarmiList(vpnCarmi);
        ExcelUtil<VpnCarmi> util = new ExcelUtil<VpnCarmi>(VpnCarmi.class);
        util.exportExcel(response, list, "carmi数据");

    }

    /**
     * 获取carmi详细信息
     */
    @PreAuthorize("@ss.hasPermi('vpn:carmi:query')")
    @GetMapping(value = "/{carmiId}")
    public AjaxResult getInfo(@PathVariable("carmiId") Long carmiId)
    {
        return success(vpnCarmiService.selectVpnCarmiByCarmiId(carmiId));
    }

    /**
     * 批量新增carmi
     */
    @PreAuthorize("@ss.hasPermi('vpn:carmi:add')")
    @Log(title = "carmi", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VpnCarmiDTO vpnCarmiDTO)
    {
        return toAjax(vpnCarmiService.insertManyVpnCarmi(vpnCarmiDTO));
    }

//    /**
//     * 新增carmi
//     */
//    @PreAuthorize("@ss.hasPermi('vpn:carmi:add')")
//    @Log(title = "carmi", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody VpnCarmi vpnCarmi)
//    {
//        return toAjax(vpnCarmiService.insertVpnCarmi(vpnCarmi));
//    }

    /**
     * 修改carmi
     */
    @PreAuthorize("@ss.hasPermi('vpn:carmi:edit')")
    @Log(title = "carmi", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VpnCarmi vpnCarmi)
    {
        return toAjax(vpnCarmiService.updateVpnCarmi(vpnCarmi));
    }

    /**
     * 删除carmi
     */
    @PreAuthorize("@ss.hasPermi('vpn:carmi:remove')")
    @Log(title = "carmi", businessType = BusinessType.DELETE)
	@DeleteMapping("/{carmiIds}")
    public AjaxResult remove(@PathVariable Long[] carmiIds)
    {
        return toAjax(vpnCarmiService.deleteVpnCarmiByCarmiIds(carmiIds));
    }
}
